package cn.kgc.servlet;

import cn.kgc.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @author: mosin
 * @version: v1.0  2022/3/21
 */
@WebServlet("/jstl")
public class JstlServvlet  extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        User user = User.builder().age(20).userName("lisi").id(1).build();
        ArrayList<User> users = new ArrayList<>();
        users.add(user);
        users.add(user);
        users.add(user);
        users.add(user);
        users.add(user);
        req.setAttribute("status",1);
        //绑定数据 实现页面的转发
        req.setAttribute("users",users);
        req.getRequestDispatcher("/user.jsp").forward(req,resp);
    }
}
